package icu.makka.yygh.controller;

import icu.makka.yygh.model.hosp.Schedule;
import icu.makka.yygh.result.Result;
import icu.makka.yygh.service.ScheduleService;
import icu.makka.yygh.service.impl.ScheduleServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@Api(tags = "排班后台管理")
@RequestMapping("admin/hosp/schedule")
public class ScheduleController {

    @Autowired
    private ScheduleServiceImpl scheduleService;

    /**
     * 查询排班规则数据
     * @param page
     * @param limit
     * @param hoscode
     * @param depcode
     * @return
     */
    @ApiOperation(value = "查询排班规则数据")
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable("page") Long page,
                                  @PathVariable("limit") Long limit,
                                  @PathVariable("hoscode") String hoscode,
                                  @PathVariable("depcode") String depcode) {
        log.info("查询排班规则数据，page={}，limit={},hoscode={},depcode={}", page, limit, hoscode, depcode);
        Map<String, Object> map = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);
        return Result.ok(map);
    }

    /**
     * 根据医院编、科室编号和工作日期，查询排班详细信息
     * @param hoscode
    * @param depcode
     * @param workData
     * @return
     */
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable("hoscode") String hoscode,
                                    @PathVariable("depcode") String depcode,
                                    @PathVariable("workDate") String workData) {
        List<Schedule> list = scheduleService.getDetailSchedule(hoscode, depcode, workData);
        return Result.ok(list);
    }
}
